﻿using CoreDome.Services;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CoreDome.ViewComponents
{
    public class MovieCountViewComponent:ViewComponent
    {
        private readonly IMovieService movieService;

        public MovieCountViewComponent(IMovieService movieService)
        {
            this.movieService = movieService;
        }
         
        public async Task<IViewComponentResult> InvokeAsync() 
        {

            var movie1 = await movieService.GetByCinemaIdAsync(1);
            var movie2 = await movieService.GetByCinemaIdAsync(2);

            var count = movie1.Count() + movie2.Count(); 

            return View(count);
        }

    }
}
